﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using DAO;
namespace BUS
{
    public class AdministratorBUS
    {
        public static List<MEMBER> GetAllAdministrator()
        {
            try
            {
                return AdministratorDAO.GetAllAdministrator();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static MEMBER GetAdministrator(int IDAdmin)
        {
            try
            {
                if (!AdministratorDAO.IsExisting(IDAdmin))
                    return null;
                return AdministratorDAO.GetAdministrator(IDAdmin);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static MEMBER GetAdministrator(string UserName,string PassWord)
        {
            try
            {
                if (!AdministratorDAO.IsExisting(UserName, PassWord))
                    return null;
                return AdministratorDAO.GetAdministrator(UserName, PassWord);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static bool Insert(MEMBER Admin)
        {
            try
            {
                if (AdministratorDAO.IsExisting(Admin.ACCOUNT.USERNAME.Trim()))
                    return false;
                Admin.MEMBER_STYLE = 1;
                Admin.ACCOUNT.ACCOUNT_STYLE = true;
                Admin.ACCOUNT.VISIBLE = true;
                return AdministratorDAO.Insert(Admin);
            }
            catch (Exception ex)
            {
                throw ex;
                
            }
        }

        public static bool updateMember(MEMBER _mMember)
        {
            try
            {
                bool isExist = AdministratorDAO.IsExisting(_mMember.IDMEMBER);
                if (!isExist)
                    return false;
                return AdministratorDAO.updateMember(_mMember);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
